package online.sh.cn.fy.common.message;

import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.axis2.AxisFault;
import org.apache.axis2.transport.http.HTTPConstants;

public class SendMessage {
public static SmsStub stub = null;
	
	static{
		try {
			stub = new SmsStub("http://gd.ums86.com:8899/sms_hb/services/Sms?wsdl");//高并发时注意使用单实例
			stub._getServiceClient().getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);//高并发时设置成true
		} catch (AxisFault e) {
			
		}
	}
	
	public static String sendMessage(String mobile,String code){
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		//发送接口,高并发请采用多线程提交
		SmsStub.Sms sms0 = new SmsStub.Sms();
		sms0.setIn0("223324");//企业编号
		sms0.setIn1("zx_rxxx");//登录名
		sms0.setIn2("shol2211");//密码
		sms0.setIn3("感谢认证【Young粉】，认证验证码为："+code+"，如非本人操作，请忽略本消息。");//短信内容
		sms0.setIn4(mobile);//手机号码
		sms0.setIn5("000"+format.format(new Date()));
		sms0.setIn6("");
		sms0.setIn7("1");
		sms0.setIn8("");
		sms0.setIn9("");
		sms0.setIn10("");
		SmsStub.SmsResponse resp;
		try {
			resp = stub.Sms(sms0);
			stub.cleanup();//使用完后cleanup
			System.out.println(resp.getOut());
			return resp.getOut();
		} catch (RemoteException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static void main(String[] args) {
		sendMessage("19964286330", "213321");
	}
}
